package technion.gc.api.interfaces;

import java.util.ArrayList;

/** Abstraction for a Graph Node.
*	Inherit and implement abstract methods.
*/
public abstract class AbstractGraphNode {
	/** Returns the neighbor list of this node
	*	
	* @return	Node's neighbors
	*/
	public abstract ArrayList<AbstractGraphNode> getNeighbors();
	
	/** Sets the neighbor list of this node.
	*	Implement dummy when useless.
	*
	* @param _neighbors	Node's neighbors
	*/
	public abstract void setNeighbors(ArrayList<AbstractGraphNode> _neighbors);
	
	/** Data object stored in the node. Passed in c'tor.
	*   Always call super with data from children.
	*/
	protected Object data;
	
	/** C'tor to make new Graph Node.
	*
	* @param _data	Node's data
	*/
	public AbstractGraphNode(Object _data) {
		data = _data;
	}
	
	/** Returns Node's data
	*	
	* @return	Node's data
	*/
	public Object getData() {
		return data;
	}
	
	/** Sets Node's data
	*	
	* @param data	Node's data
	*/
	public void setData(Object data) {
		this.data = data;
	}
	
	@Override
	public boolean equals(Object other) {
		AbstractGraphNode _other = (AbstractGraphNode)other;
		return other != null && data.equals(_other.getData());
	}
	
	@Override
	public int hashCode() {
		return data.hashCode();
	}
}
